<template>
    <div class="app-container">
        <el-row>
            <el-col :span="14">
                <div class="divcss5">
                    <el-form label-width="80px" :model="PtPatientVo">
                        <el-form-item  label="患者信息编号">
                            <el-input :placeholder="ptdeId"></el-input>
                        </el-form-item>
                        <el-form-item  label="姓名">
                            <el-input v-model="PtPatientVo.ptName"></el-input>
                        </el-form-item>
                        <el-form-item  label="年龄">
                            <el-input v-model="PtPatientVo.ptdtAge"></el-input>
                        </el-form-item>
                        <!-- <el-form-item label="住院号">
                            <el-input v-model="PtPatientVo.ptdtCheckCode"></el-input>
                        </el-form-item> -->
                        <el-form-item  label="检查设备">
                            <el-input v-model="PtPatientVo.ptdtCheckMachine"></el-input>
                        </el-form-item>
                        <!-- <el-form-item label="身高">
                            <el-input v-model="PtPatientVo.ptdtHeight"></el-input>
                        </el-form-item>
                        <el-form-item label="体重">
                            <el-input v-model="PtPatientVo.ptdtWeight"></el-input>
                        </el-form-item> -->

                        <el-form-item  label="检查项目">
                            <el-select @change="changeCheckName" v-model="PtPatientVo.ptdtCheckName" clearable
                                placeholder="请选择检查项目">
                                <el-option v-for="item in checkNameList" :key="item" :label="item" :value="item">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="病史">
                            <el-input type="textarea" :rows="10" v-model="PtPatientVo.ptdtBgReadyTxt"></el-input>
                        </el-form-item>
                        <el-form-item label="检查所见">
                            <el-input type="textarea" :rows="10" v-model="PtPatientVo.ptdtCheckSjTxt"></el-input>
                        </el-form-item>
                        <el-form-item label="检查意见">
                            <el-input type="textarea" :rows="10" v-model="PtPatientVo.ptdtCheckyjTxt"></el-input>
                        </el-form-item>
                    </el-form>
                    <el-button type="primary" @click="onSubmit">保存</el-button>
                </div>
            </el-col>
            <el-col :span="9">
                <div class="rightCell">
                    <el-tabs v-model="activeName" @tab-click="handleNodeClick">
                        <el-tab-pane label="历史" name="first">
                            <el-card>
                                <el-descriptions title="病史"></el-descriptions>
                                <div class="contents" v-for="(item,index) in HistoryVo" :key="index">
                                    <div class="text-item">
                                        <span>
                                            {{item.ptdtCheckDate}}
                                        </span>
                                        <p></p>
                                        <span>
                                            {{item.ptdtBgReadyTxt}}
                                        </span>
                                    </div>
                                </div>
                            </el-card>
                            <el-card>
                                <el-descriptions title="检查所见"></el-descriptions>
                                <div class="text-item" v-for="(item,index) in HistoryVo" :key="index">
                                    <span>
                                        {{item.ptdtCheckDate}}
                                    </span>
                                    <p></p>
                                    <span>
                                        {{item.ptdtCheckSjTxt}}
                                    </span>
                                </div>
                            </el-card>
                            <el-card>
                                <el-descriptions title="检查意见"></el-descriptions>
                                <div class="text-item" v-for="(item,index) in HistoryVo" :key="index">
                                    <span>
                                        {{item.ptdtCheckDate}}
                                    </span>
                                    <p></p>
                                    <span>
                                        {{item.ptdtCheckyjTxt}}
                                    </span>
                                </div>
                            </el-card>
                        </el-tab-pane>
                        <el-tab-pane label="截图" name="second">
                            <div class="contents"></div>
                        </el-tab-pane>
                        <el-tab-pane label="模板" name="third">
                            <div class="contents">
                                <el-tree :data="data" :props="defaultProps" @node-click="getTemplateInfo"></el-tree>
                            </div>
                            <!-- <el-card class="box-card" lable="检查所见" :size="600">
                                {{TemplateInfo.libCheckSj}}
                            </el-card>
                            <el-card class="box-card" lable="检查意见">
                                {{TemplateInfo.libCheckYj}}
                            </el-card> -->
                        </el-tab-pane>
                        <el-tab-pane label="序列" name="fourth">
                            <div class="contents"></div>
                        </el-tab-pane>
                    </el-tabs>

                </div>
            </el-col>
        </el-row>



    </div>


</template>
<script>
    import teacher from '@/api/report/teacher'
    export default {
        data() {
            return {
                activeName: 'first',
                formInline: {
                    user: '111',
                    region: ''
                },
                patientInfo: {
                },
                checkNameList: [],
                ptdeId: this.$route.query.id,
                patientId: this.$route.query.patientId,
                ptdtOperDatetime: '',
                PtPatientVo: {

                },
                defaultProps: {
                    label: 'label',
                    children: 'children'
                },
                data: [],
                DetailslList: {},
                Survey: {},
                HistoryVo: [],
                TemplateInfo: {}
            }
        },
        created() {
            this.getDropDownCheckName()
            this.getPatient(this.ptdeId)
            this.getBgReady()

        },
        // mounted(){
        //登created加载好之后会执行的
        // },
        methods: {
            //点击节点触发
            getTemplateInfo(e) {
                if (e.children == null) {
                    teacher.getTemplateInfo(e.id, e.pid).then(
                        response => {
                            this.TemplateInfo = response.data || {}
                            this.PtPatientVo.ptdtCheckSjTxt = this.TemplateInfo.libCheckSj
                            this.PtPatientVo.ptdtCheckyjTxt = this.TemplateInfo.libCheckYj
                        }
                    )
                }

            },
            getBgReady() {
                teacher.getHistory(this.patientId,this.ptdeId).then(
                    response => {
                        this.HistoryVo = response.data || {}
                    }
                )
            },
            //标签页切换触发
            handleNodeClick(e) {
                switch (this.activeName) {
                    case 'first':
                        this.getBgReady()
                        break
                    case 'second':
                        console.log('second')
                        break
                    case 'third':
                        teacher.getTemplate().then(response => {
                            this.data = response.data.public
                        })
                        break
                    case 'four':
                        console.log('fourth')
                        break
                }

            },
            changeCheckName(e) {
                this.$set(this.PtPatientVo, 'ptdtCheckName', e)
            },
            getDropDownCheckName() {
                teacher.getDropDownCheckName().then(response => {
                    this.checkNameList = response.data
                })
            },
            //获取患者信息
            getPatient(ptdeId) {
                teacher.getPatient(ptdeId).then(response => {
                    this.PtPatientVo = response.data
                })
            },
            //保存
            onSubmit() {
                this.$confirm('确定保存, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {

                    teacher.updatePatient(this.PtPatientVo)
                        .then(response => {
                            this.$message({
                                type: 'success',
                                message: '保存成功!'
                            });
                            console.log(this.PtPatientVo);
                    
                            this.PtPatientVo = null
                            this.$router.push('/teacher/info'); //  ?id=1
                        })
                })
            },

        }
    }
</script>
<style>
   
    .contents {
        min-height: 300px;
    }

    .text {
        font-size: 14px;
    }

    .item {
        padding: 18px 0;
    }

    /* .box-card {
        width: 600px;
    }  */

    .divcss5 {
        width: 100%;
        padding: 15px;
        min-height: 100vh;
        border: 1px solid #DCDFE6;
    }

    .el-tabs {
        margin-top: -14px;
    }

    .rightCell {
        margin-left: 10px;
        border: 1px solid #DCDFE6;
        padding: 15px;
        min-height: 100vh;
    }

    /* .el-card-define {
        min-height: 100%;
        height: 100%;
    }

    .el-card-define>>>.el-card__body {
        height: 100%;
    } */
/* 
    .el-card__body {
        min-height: 100px;
        max-height: 250px;
        overflow: auto;
        overflow-x: hidden;
        word-wrap: break-word;
    } */
</style>